classdef vehicle < handle
    %UNTITLED2 Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        vehicle_type=''           %string eg 'SUV'
        camera_angle=''           %string eg 's1'
        original_image
        cropped_image
        wavelet_tree
        wave_features=[]          %float/double array
        selected_wave_features=[] %indecies of wave features selected
        selected_wave_features2=[]
        hog_featuers=[]           %float/double array
        selected_hog_features=[]  %indecies of hog features selected
        selected_hog_features2=[] 
        
    end
    
    methods
        function obj=vehicle(imgpath)
            obj.original_image=imread(imgpath);
            obj.cropped_image = imcrop(obj.original_image,[13 130 619 215]);
        end
            
        
        function calculate_wave_features(obj,wavedesc, level)
            img=imresize(obj.cropped_image, 0.25);
            features=wpdec2(img, level, wavedesc); data=read(features, 'data');
            %[data, s]=wavedec2(img, level, wavedesc);
            obj.wave_features=data(:);
            %disp(size(data))
            %obj.wavelet_tree=features;
        end
        
        function img=recompose_image_from_wavelets(obj)
            img=wprec2(obj.wavelet_tree);
        end
        %caliculate
        function calculate_hog(obj,cellSize)
            %I = imread(fileToRead2);
            %cellSize = cellsize;
            se = strel('disk',2);
            grayimage = rgb2gray(obj.cropped_image); % convert it to gray scale
            A = single(grayimage);%cast type to single
            %[hogimageCell] = vl_hog(A,cellSize, 'verbose');
            [hogimageCell] = vl_hog(A,cellSize);
            %convert the 3dimention array to 1 demention
            cvs = [];
            %walk through array 
            %size(hogimageCell)
            %size(hogimageCell,1)
            for j=1:size(hogimageCell,3)
                for k=1:size(hogimageCell,1)
                    cvs = horzcat(cvs, hogimageCell(k,:,j));
                end
            end
            obj.hog_featuers = cvs;
            %hog_features = vertcat(complete,cvs);
        end
    end
    
end

